﻿
''' <summary>
''' 用户操作
''' </summary>
''' <remarks></remarks>
Public Class OperateLogClass

    ''' <summary>
    ''' 记录操作日志
    ''' </summary>
    ''' <param name="uid">用户ID</param>
    ''' <param name="uName">用户真实姓名</param>
    ''' <param name="msg">操作内容</param>
    ''' <param name="OpType">操作类型</param>
    ''' <remarks></remarks>
    Public Shared Sub Write(ByVal uid As String, ByVal uName As String, ByVal msg As String, ByVal OpType As tbccLogOperateType)
        '操作类型
        'Dim operateType As String
        'operateType = System.Enum.GetName(GetType(tbccLogOperateType), OpType)

        Dim strSql As String
        strSql = "Insert Into tbccLog(uid,uName,opType,opTime,message,machineName) Values(?p0,?p1,?p2,?p3,?p4,?p5)"

        Dim i As Integer
        Dim p(5) As MySql.Data.MySqlClient.MySqlParameter
        For i = 0 To p.Length - 1
            p(i) = New MySql.Data.MySqlClient.MySqlParameter()
        Next

        i = 0
        p(i).ParameterName = "p" + i.ToString : p(i).Value = uid

        i += 1
        p(i).ParameterName = "p" + i.ToString : p(i).Value = uName

        i += 1
        p(i).ParameterName = "p" + i.ToString : p(i).Value = OperateTypeItem.GetName(OpType)

        i += 1
        p(i).ParameterName = "p" + i.ToString : p(i).Value = Now.ToString("yyyy-MM-dd HH:mm:ss")

        i += 1
        p(i).ParameterName = "p" + i.ToString : p(i).Value = msg

        i += 1
        p(i).ParameterName = "p" + i.ToString : p(i).Value = System.Environment.MachineName


        SqlHelper.ExecuteNonQuery(strSql, p)

    End Sub

    ''' <summary>
    ''' 查询日志
    ''' </summary>
    ''' <param name="opType">操作类型</param>
    ''' <param name="uName">操作人</param>
    ''' <param name="dtFrom">起始日期</param>
    ''' <param name="dtTo">终止日期</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetLog(ByVal opType As tbccLogOperateType, ByVal uName As String, ByVal dtFrom As DateTime, ByVal dtTo As DateTime) As DataTable
        Dim ds As DataSet
        ds = Nothing

        Return ds.Tables(0)
    End Function

End Class
